package courseClassStatistic;

import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class reducer extends Reducer<Text, DoubleWritable, Text, DoubleWritable> {
    public void reduce(Text key, Iterable<DoubleWritable> values, Context context) throws IOException,InterruptedException{
        int count = 0;
        double scores = 0;
        for(DoubleWritable value:values){
            scores += value.get();
            count ++;
        }
        context.write(key, new DoubleWritable(scores/count));
    }
}
